<template>
    <view class="globe_back">
        <view class="box">
            <view class="setUp">
                <view class="flex setUpList">
                    <view class="title">店铺名称</view>
                    <view>{{ formData.title }}</view>
                </view>
                <view class="flex setUpList">
                    <view class="title">联系电话</view>
                    <view>{{ formData.phone }}</view>
                </view>
                <u-picker :show="show" :columns="columns" @cancel="cancel" @confirm="confirm"></u-picker>
                <view class="flex setUpList">
                    <view class="title">入驻类型</view>
                    <view @click="show == true">{{ formData.type }}</view>
                </view>
                <view class="flex setUpList">
                    <view class="title">店铺地址</view>
                    <view class="flex from-title-box align_items_center justify_content_between" style="width: 80%" @click="report_map">
                        <input
                            class="f_28 cl_00091A pb_16"
                            disabled
                            placeholder-class="cl_CCCED1"
                            v-model="formData.full_address"
                            type="number"
                            value=""
                            placeholder="请选择店铺地址"
                        />
                        <image class="img_32" src="https://jiuyuan.smomotbo.com/static/imgs/me-report/posi-icon.png" mode=""></image>
                    </view>
                </view>
            </view>
            <view>
                <!-- 店铺头像 -->
                <view class="back_fff br_16 p_32 m_16 mt_32">
                    <view class="flex">
                        <view class="from-title-box title">
                            <text class="f_28 cl_333A47">店铺头像</text>
                        </view>
                        <view class="imm_imgbox">
                            <!-- <view class="imm_img">
											<image class="img_140" src="img" mode="widthFix"></image>
										</view> -->

                            <view style="display: inline-block" @click="handleUpload('logo')">
                                <image class="img_140" :src="$lz.cdn(formData.logo, 3, 'imgs/updata-img.png', 1)" mode="widthFix"></image>
                            </view>
                            <view class="f_20 cl_999CA3">建议上传尺寸为1:1的图片</view>
                        </view>
                    </view>
                </view>
            </view>
            <view class="addBtn back_3377FF br_24 cl_fff mt_24">保存</view>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            show: false,
            columns: [['加盟商家', '加盟商家1', '加盟商家2']],
            formData: {
                title: '',
                phone: '',
                type: '',
                latitude: '',
                longitude: '',
                full_address: ''
            }
        };
    },
    methods: {
        confirm(e) {
            console.log(e.value[0]);
            this.type = e.value[0];
            this.show = false;
        },
        cancel() {
            this.show = false;
        },
        // 地址
        report_map() {
            // let _this = this
            uni.chooseLocation({
                success: (res) => {
                    console.log(res);
                    this.formData.latitude = res.latitude;
                    this.formData.longitude = res.longitude;
                    this.formData.full_address = `${res.address}-${res.name}`;
                    // this.getLocation();
                }
            });
        },
        // 店铺头像
        handleUpload(field) {
            let that = this;
            uni.chooseImage({
                count: 1,
                sourceType: ['album', 'camera'],
                sizeType: ['original', 'compressed'],
                success: (chooseImageRes) => {
                    console.log('chooseImageRes', chooseImageRes);
                    const path = chooseImageRes.tempFilePaths[0];
                    upload(path, 'image').then(({ data }) => {
                        const { hash } = data.data;
                        that.formData[field] = hash;
                    });
                }
            });
        }
    }
};
</script>

<style scoped lang="scss">
.box {
    padding: 32rpx;
    .setUp {
        background: white;
        border-radius: 24rpx;
        padding: 24rpx;
        font-size: 28rpx;
        .title {
            width: 148rpx;
        }
        .setUpList {
            padding: 32rpx 0;
        }
    }
    .title {
        width: 148rpx;
    }
    .addBtn {
        width: 686rpx;
        height: 100rpx;
        line-height: 100rpx;
        text-align: center;
        margin: 24px auto;
    }
}
</style>
